/**
 * GULP Required components
 */
var gulp = require('gulp');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
// var livereload = require('gulp-livereload');

//bower path
var bower_components_path = './bower_components/**';

//library path
var lib_path = './www/lib';
var sass_path = './sass/*.scss';
var js_path = './www/lib/zhx.monitor/*.js';

//default task
gulp.task('default', ['sass','script']);

//sass to css and minify
gulp.task('sass', function(done) {
  gulp.src([ sass_path ])
    .pipe(sass())
    .on('error', sass.logError)
    .pipe(gulp.dest('./www/lib/zhx.monitor/css/'))
    .pipe(minifyCss({
      keepSpecialComments: 0
    }))
    .pipe(rename({ extname: '.min.css' }))
    .pipe(gulp.dest('./www/lib/zhx.monitor/css/'))
    .on('end', done);
});

//copy bower_components to www/lib
gulp.task('makeDpc',function(){
  gulp.src(bower_components_path)
    .pipe(gulp.dest(lib_path));
});

//sass auto
gulp.task('watch', function() {
  gulp.watch(sass_path, ['sass']);
});

